package cn.chinaflame.pagodas.web;


import cn.chinaflame.pagodas.Result.Result;
import cn.chinaflame.pagodas.annotation.ApiDoc;
import cn.chinaflame.pagodas.dto.PaOrderDto;

import cn.chinaflame.pagodas.req.PaOrderQryReq;

import cn.chinaflame.pagodas.service.FileDealWithService;
import cn.chinaflame.pagodas.service.PaProductPointService;

import cn.chinaflame.pagodas.service.WrmNIService;
import cn.chinaflame.pagodas.vo.LightVO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.util.List;

/**
 * 佛龛订单相关接口
 *
 * @author boming
 * @date 2018年6月21日 下午2:25:16
 */
@RestController
@Transactional(rollbackFor = Exception.class)
@RequestMapping(value = "/openapi/v1/pagodas/test/")
public class WwtTestAPI {
    private static Logger log = LoggerFactory.getLogger(WwtTestAPI.class);
    @Autowired
    private PaProductPointService paProductPointService;
    @Autowired
    private WrmNIService wrmNIService;
    @Autowired
    private FileDealWithService fileDealWithService;
    /**
     * 点灯接口
     *
     * @return
     */
//	@RestAction
    @PostMapping(value = "diandeng")
    @ApiDoc(value = PaOrderQryReq.class, result = PaOrderDto.class)
    public Object dianDeng(String lightno,String obj,String bless) {
        log.info("订单列表查询req:{}");
        JSONArray param = new JSONArray();
        JSONObject p = new JSONObject();
        p.put("lightno", lightno);
        p.put("obj", obj);
        p.put("bless", bless);
        param.add(p);
        LightVO lightVO =wrmNIService.wwtLightSend(lightno,obj,bless);
        //List<LightVO> list =  paProductPointService.lightCheckAndSend(param);
        //LightVO lightVO = list.get(0);

        log.info("返回值"+lightVO.getResult());
       return lightno;
    }

    /**
     * 清灯接口
     *
     * @return
     */
//	@RestAction
    @PostMapping(value = "qingdeng")
    @ApiDoc(value = PaOrderQryReq.class, result = PaOrderDto.class)
    public Object qingDeng(@RequestBody PaOrderQryReq req) {

        List<LightVO> list =  paProductPointService.lightClear("0201010101");
        log.info("返回值"+list);
        return list;
    }

    /**
     * 闪烁接口
     *
     * @return
     */
    @PostMapping(value = "shanshuo")
    @ApiDoc(value = PaOrderQryReq.class, result = PaOrderDto.class)
    public Object shanShuo(@RequestBody PaOrderQryReq req) {

        List<LightVO> list =  paProductPointService.lightSearchByFlash("0201010101");
        log.info("返回值"+list);
        return list;
    }

    /**
     * 寻灯接口
     *
     * @return
     */
    @PostMapping(value = "xundeng")
    @ApiDoc(value = PaOrderQryReq.class, result = PaOrderDto.class)
    public Object xunDeng(@RequestBody PaOrderQryReq req) {

        List<LightVO> list =  paProductPointService.lightCheck("0201010101");
        log.info("返回值"+list);
        return list;
    }









}













